//
//  LayoutCellScroll.m
//  ebook
//
//  Created by 吴超飞 on 2017/3/16.
//  Copyright © 2017年 Moton. All rights reserved.
//

#import "LayoutCellScroll.h"
#import "LayoutCellTable.h"

@interface LayoutCellScroll()

@property (nonatomic, strong) UIScrollView *scrollView;

@end

@implementation LayoutCellScroll


- (void)drawRect:(CGRect)rect {
    
    [self addSubview:self.scrollView];
}

- (UIScrollView *)scrollView {
    
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, TitleHeight, MTScreenW, [LayoutCellTable oneRowHeight])];
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.pagingEnabled = YES;
        _scrollView.backgroundColor = [UIColor redColor];
    }
    return _scrollView;
}

-(void)reloadData{

    NSInteger len = isIpad?6:4;
    for (int i=0; i<self.layOutType.rows; i++) {
        LayoutCellTable *table = [[LayoutCellTable alloc]initWithFrame:CGRectMake(i*MTScreenW, 0, MTScreenW, [LayoutCellTable oneRowHeight])];
        table.isNoHead = YES;
        NSArray *array = [self.dataArray subarrayWithRange:NSMakeRange(i*len, len)];
        table.dataArray = array;
        [table reloadData];
        [self.scrollView addSubview:table];
    }
}

+(float)viewHeight:(LayoutType *)layoutType{
    
    return TitleHeight + [LayoutCellTable oneRowHeight];
}


@end
